/**
 * @author : cyb1010
 * @date   : 2024-04-16 17:13:45
 * @file   : P_4223_期望逆序对.cpp
 */
#include <bits/stdc++.h>
using namespace std;
#define fo(s) freopen(s ".in", "r", stdin), freopen(s ".out", "w", stdout)
#define fi first
#define se second
typedef double db;
typedef long double ldb;
typedef long long ll;
typedef unsigned long long ull;
const int N = 500010, mod = 998244353;
int __, n, k, a[N], q;
ll ans, inv[N];

struct BIT {
    int b[N];
    int lb(int x) { return x & -x; }
    void clear() { fill(b + 1, b + 1 + n, 0); }
    void add(int x, int y) {
        while (x <= n) b[x] = (b[x] + y) % mod, x += lb(x);
    }
    int qry(int x) {
        int res = 0;
        while (x) res = (res + b[x]) % mod, x ^= lb(x);
        return res;
    }
} cnt, pos;

struct mat {
    ll a[7][7]; //(A,B),(B,A),(A,C),(C,A),(B,C),(C,B),(C,C)
    mat operator*(const mat &x) {
        mat res;
        memset(res.a, 0, sizeof(res));
        for (int i = 0; i < 7; i++)
            for (int j = 0; j < 7; j++)
                for (int k = 0; k < 7; k++)
                    res.a[i][j] += a[i][k] * x.a[k][j] % mod;
        for (int i = 0; i < 7; i++)
            for (int j = 0; j < 7; j++) res.a[i][j] %= mod;
        return res;
    }
} tr;
ll c2(int x, int y) { return (x * (x - 1ll) / 2 + y) % mod; }
ll qp(ll x, ll k, ll res = 1) {
    x %= mod, res %= mod;
    while (k) {
        if (k & 1) res = res * x % mod;
        x = x * x % mod, k >>= 1;
    }
    return res;
}
mat qp(mat x, ll k) {
    mat res;
    memset(res.a, 0, sizeof(res.a)), res.a[0][0] = 1;
    while (k) {
        if (k & 1) res = res * x;
        x = x * x, k >>= 1;
    }
    return res;
}
int work() {
    cnt.clear(), pos.clear(), ans = 0;
    tr = mat{{{c2(n - 2, 0), 1, n - 2, 0, 0, n - 2, 0},
              {1, c2(n - 2, 0), 0, n - 2, n - 2, 0, 0},
              {1, 0, c2(n - 2, n - 3), 1, 1, 0, n - 3},
              {0, 1, 1, c2(n - 2, n - 3), 0, 1, n - 3},
              {0, 1, 1, 0, c2(n - 2, n - 3), 1, n - 3},
              {1, 0, 0, 1, 1, c2(n - 2, n - 3), n - 3},
              {0, 0, 1, 1, 1, 1, c2(n, mod - 4)}}};
    tr = qp(tr, k), inv[1] = 1;
    for (int i = 2; i <= n; i++) inv[i] = inv[mod % i] * (mod - mod / i) % mod;
    for (int i = 1, x, tmp; i <= n; i++) {
        x = a[i];
        int lc = cnt.qry(x), hc = i - lc - 1;
        int lp = pos.qry(x), hp = c2(i, mod - lp);
        cnt.add(x, 1), pos.add(x, i);

        // (A,B)
        ans = (ans + tr.a[0][0] * hc) % mod;

        // (B,A)
        ans = (ans + tr.a[0][1] * lc) % mod;

        // (A,C)
        tmp = inv[n - 2] * (hc * (n - 1ll) % mod + mod - hp) % mod;
        ans = (ans + tmp * tr.a[0][2]) % mod;
        tmp = inv[n - 2] * (lp + mod - lc) % mod;
        ans = (ans + tmp * tr.a[0][2]) % mod;

        // (C,A)
        tmp = inv[n - 2] * (hp + mod - hc) % mod;
        ans = (ans + tmp * tr.a[0][3]) % mod;
        tmp = inv[n - 2] * (lc * (n - 1ll) % mod + mod - lp) % mod;
        ans = (ans + tmp * tr.a[0][3]) % mod;

        // (B,C)
        tmp = inv[n - 2] * hc % mod * (n - i) % mod;
        ans = (ans + tmp * tr.a[0][4]) % mod;
        tmp = inv[n - 2] * lc % mod * (i - 2) % mod;
        ans = (ans + tmp * tr.a[0][4]) % mod;

        // (C,B)
        tmp = inv[n - 2] * hc % mod * (i - 2) % mod;
        ans = (ans + tmp * tr.a[0][5]) % mod;
        tmp = inv[n - 2] * lc % mod * (n - i) % mod;
        ans = (ans + tmp * tr.a[0][5]) % mod;

        // (C,C)
        tmp = inv[2] * (i - 1) % mod;
        ans = (ans + tmp * tr.a[0][6]) % mod;
    }
    return ans;
}

int main() {
    fo("random");
    cin.tie(0)->sync_with_stdio(0);
    cin >> n >> k >> q;
    for (int i = 1; i <= n; i++) cin >> a[i];
    ll v0 = qp(c2(n, 0), mod - 2);
    cout << qp(v0, k, work()) << '\n';
    for (int x, y; q--;) {
        cin >> x >> y, swap(a[x], a[y]), k--;
        cout << qp(v0, k, work()) << '\n';
    }
    return 0 ^ __ ^ 0;
}